package com.kehao.controller;

import com.kehao.dto.StuClassDto;
import com.kehao.service.StuClassService;
import com.kehao.vo.StuClassRec;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "班级请求ControllerApi")
@RestController
@RequestMapping("/class")
@RequiredArgsConstructor
public class StuClassController {

    private final StuClassService stuClassService;

    //查
    @ApiOperation(value = "查询所有班级方法", response = StuClassRec.class, responseContainer = "List")
    @GetMapping()
    public List<StuClassRec> getAll() {

        return stuClassService.getAll();

    }

    //查单个
    @ApiOperation(value = "查询单个班级方法", response = StuClassRec.class)
    @GetMapping("/{id}")
    public StuClassRec getOne(@PathVariable String id) {

        return stuClassService.getByOne(id);

    }

    //增
    @ApiOperation(value = "添加学生班级方法", response = boolean.class)
    @PostMapping()
    public boolean add(@RequestBody StuClassDto stuClassDto) {
        return stuClassService.add(stuClassDto);
    }

    //删
    @ApiOperation(value = "删除学生班级方法", response = boolean.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name="student_id",value = "学生id",defaultValue = "1",dataType = "Integer"),
//            @ApiImplicitParam(name="userInfo",value = "用户信息",defaultValue = "nothing",dataType = "String")
    })
    @DeleteMapping("/{student_id}")
    public boolean del(@PathVariable String student_id) {
        return stuClassService.del(student_id);
    }

    //改
    @ApiOperation(value = "修改学生班级方法", response = boolean.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name="student_id",value = "学生id",defaultValue = "1",dataType = "Integer"),
//            @ApiImplicitParam(name="userInfo",value = "用户信息",defaultValue = "nothing",dataType = "String")
    })
    @PutMapping
    public boolean del(@RequestBody StuClassDto stuClassDto) {
        return stuClassService.updateClass(stuClassDto);
    }


}
